home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 728 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. From: gusty@clark.net (Harlan Messinger)
  2. Message-ID: <4iat2h$pk5@clarknet.clark.net>
  3. X-Original-Date: 15 Mar 1996 04:52:33 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 15 Mar 96 07:40:07 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: No way to define some extern consts?
  9. Organization: Clark Internet Services, Inc., Ellicott City, MD USA
  10. References: <sdouglas-1403961511440001@193.131.176.202>
  11. X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMUke6+EDnX0m9pzZAQG85QF9HVS/M0/QXsSo+Vhk3OeT14Hl6Ndlk97u
  14.     zw9s/6xcjoJbrSoWJUth3Gy9/qnMNfd2
  15.     =uSw0
  16.  
  17. scott douglass (sdouglas@armltd.co.uk) wrote:
  18. : Hello all,
  19. : Given a class type with only a no-argument contstrutor:
  20. : struct T { T(); /* ... */ };  // assume no other ctors
  21. : Is there any way to define an extern const object of class T?
  22. : extern const T t; // nope:  this is a declaration
  23. : const T t2; // nope:  this is a definition, but t2 is not extern
  24.  
  25. This is the correct one. The object ISN'T external from the point of view 
  26. of the module in which it's defined! You'll declare
  27.  
  28.     extern const T t2;
  29.  
  30. in the header file, but define
  31.  
  32.     const T t2;
  33.  
  34. as a global non-static object in the one source file in which you want it
  35. to reside. 
  36. ---
  37. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  38. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  39. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  40. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  41. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  42.